package com.ciwong.epaper.modules.epaper.util;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;

import com.ciwong.epaper.R;
import com.ciwong.epaper.util.DeviceUtil;
import com.ciwong.epaper.util.DisplayUtils;

/**
 * @description:
 * @author: wyk
 * @time: 2021/6/23 17:38
 */
public class TeaWorkDialog extends Dialog {

    private View workHintDialogView;
    private String workName;
    private String endTime;
    private String workMessage;
    private int x轴的偏移量;
    private int y轴的偏移量;
    private int 屏幕宽度;
    private boolean isundowork=false;

    public TeaWorkDialog(@NonNull Context context, View workHintDialogView, int x轴的偏移量, int y轴的偏移量,int 屏幕宽度, boolean isundowork) {
        super(context,R.style.round_corner_dialog);
        this.workHintDialogView = workHintDialogView;
        this.workName = workName;
        this.endTime = endTime;
        this.workMessage = workMessage;
        this.x轴的偏移量 = x轴的偏移量;
        this.y轴的偏移量 = y轴的偏移量;
        this.屏幕宽度 = 屏幕宽度;
        this.isundowork=isundowork;
        init();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    private void init() {
        Window window = getWindow();
        WindowManager.LayoutParams attributes = window.getAttributes();
        attributes.gravity = Gravity.TOP;
        /*LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DeviceUtil.getDeviceWidth(getContext())
                - DisplayUtils.dip2px(getContext(), 16)
                , LinearLayout.LayoutParams.WRAP_CONTENT);*/
        LinearLayout publish_dk_work_lay =  workHintDialogView.findViewById(R.id.publish_dk_work_lay);
        LinearLayout attention_work_lay =  workHintDialogView.findViewById(R.id.attention_work_lay);
        //(DeviceUtil.getDeviceWidth(getContext())/2)-30
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams((DeviceUtil.getDeviceWidth(getContext())/2)
                - DisplayUtils.dip2px(getContext(), 20), LinearLayout.LayoutParams.WRAP_CONTENT);



        addContentView(workHintDialogView,params);



       /* if(isundowork){
            tv_homework_end_time.setVisibility(View.GONE);
        }else {
            tv_homework_end_time.setVisibility(View.VISIBLE);

        }
        tv_homework_name.setVisibility(View.GONE);
*/
        attributes.x = x轴的偏移量;
        attributes.y = 65;
//        attributes.width = 屏幕宽度/2;
//        attributes.y = y轴的偏移量+ DisplayUtils.dip2px(getContext(),7)-DisplayUtils.dip2px(getContext(),6);
        window.setAttributes(attributes);

    }
}
